package com.qupeng.demo.kafka.kafkaspringbootproducer.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResponse<T> implements Serializable {
    private String code = "000";
    private String msg = "Success.";
    private String service = "";
    private T data;
    private List<CommonResponse> responseStack = new ArrayList<>();

    public CommonResponse(String code, String msg, String service, T data) {
        this.code = code;
        this.msg = msg;
        this.service = service;
        this.data = data;
    }

    public CommonResponse(String code, String msg, String service) {
        this.code = code;
        this.msg = msg;
        this.service = service;
    }

    public CommonResponse(String service, T data) {
        this.service = service;
        this.data = data;
    }

    public CommonResponse(String service) {
        this.service = service;
    }

    public CommonResponse<T> add(CommonResponse response) {
        this.responseStack.add(response);
        return this;
    }
}
